package org.finesys.chat.core.base.agent;

import org.finesys.ai.core.chat.json.JsonObjectSchema;

import java.util.Objects;

public class ToolSpecification {

    private final String name;
    private final String description;
    private final JsonObjectSchema parameters;


    private ToolSpecification(Builder builder) {
        this.name = builder.name;
        this.description = builder.description;
        this.parameters = builder.parameters;
    }

    public String name() {
        return this.name;
    }

    public String description() {
        return this.description;
    }

    public JsonObjectSchema parameters() {
        return this.parameters;
    }


    public static Builder builder() {
        return new Builder();
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) return true;
        if (object == null || getClass() != object.getClass()) return false;
        ToolSpecification that = (ToolSpecification) object;
        return Objects.equals(name, that.name) && Objects.equals(description, that.description) && Objects.equals(parameters, that.parameters);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, description, parameters);
    }

    @Override
    public String toString() {
        return "ToolSpecification{" +
                "name='" + name + '\'' +
                ", description='" + description + '\'' +
                ", parameters=" + parameters +
                '}';
    }

    public static final class Builder {
        private String name;
        private String description;
        private JsonObjectSchema parameters;

        private Builder() {
        }

        public Builder name(String name) {
            this.name = name;
            return this;
        }

        public Builder description(String description) {
            this.description = description;
            return this;
        }

        public Builder parameters(JsonObjectSchema parameters) {
            this.parameters = parameters;
            return this;
        }

        public ToolSpecification build() {
            return new ToolSpecification(this);
        }
    }
}
